<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>查询结果</title>
  <link href="../../css/style.css" rel="stylesheet" type="text/css">
  <script language="javascript" src="../../js/clientSideApp.js"></script>
  <script language="JavaScript" type="text/javascript" src="../../js/win_center.js"></script>
  <link href="../../bootstrap-3.3.7-dist/css/bootstrap.css" rel="stylesheet">

  <script src="../../bootstrap-3.3.7-dist/js/jquery-3.4.1.min.js"></script>
  <script src="../../bootstrap-3.3.7-dist/js/bootstrap.js"></script>
  <SCRIPT language=JavaScript type=text/JavaScript>
    function windowOpen(theURL,winName,features,width,hight,scrollbars,top,left)
    {
      var parameter="top="+top+",left="+left+",width="+width+",height="+hight;
      if(scrollbars=="no")
      {parameter+=",scrollbars=no";}
      else
      {parameter+=",scrollbars=yes";}
      window.open(theURL,winName,parameter);
    }
  </SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
        <tr>
          <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
          <td valign="bottom" class="title">报损单查询</td>
        </tr>
      </table></td>
    </tr>
  </table>
  <br>
  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="table0001">
    <tr>
      <td class="td_page">报损单编号：
        <input name="textfield2" type="text" class="frmid" size="20">　

        <input type="button"  class="button_select" onClick="fPopUpCalendarDlg('PARA_YM_NOW1')">

        <input name="Submit" type="button" class="select01" value=" 查询 ">


      </td>
    </tr>
  </table>
  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="table0002">
    <tr>
      <td class="td_page">
        报损单填写人工号：
        <input name="textfield2" type="text" class="staid" size="20">　
        报损单填写日期：
        <input name="textfield2" type="date" class="frmdate" size="20">
        <input type="button"  class="button_select" onClick="fPopUpCalendarDlg('PARA_YM_NOW1')">

        <input name="Submit" type="button" class="select02" value=" 查询 ">


      </td>
    </tr>
  </table>
  <br>
  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="table01">
    <tr class="_tr1">
      <td class="td_top">报损单单号</td>
      <td class="td_top">报损单填写人</td>
      <td class="td_top">报损单填写日期</td>
      <td class="td_top">审核日期</td>
      <td nowrap class="td_top">操作</td>

    </tr>
    <tr>
      <td class="td07"></td>
      <td class="td07"></td>
      <td class="td07"></td>
      <td class="td07"></td>
      <td class="td07">
        <button type='button' name='addgoods' data-toggle='modal' aria-pressed='false' data-target='#exampleModalCenter3' class='select' ><span >查看</span></button>
      </td>


    </tr>

  </table>
  <table width="95%"  border="0" cellpadding="0" cellspacing="0" class="table02" align="center">
    <tr>
      <td height="30" align="right"><img src="../../images/1.gif" width="4" height="5" align="absmiddle"> 首页　 <img src="../../images/2.gif" width="3" height="5" align="absmiddle"> 上一页　 <img src="../../images/2-2.gif" width="3" height="5" align="absmiddle"> 下一页　 <img src="../../images/3.gif" width="4" height="5" align="absmiddle"> 末页　　共 1 页 1 条记录</td>
    </tr>
  </table>
</form>
</body>
</html>
<script src="../../js/jquery.js"></script>
<script>
<!--给三个输入框绑定事件-->
    $(".frmid").blur(function () {
      if($(this).val()!=""){

        $(".table0002").find("input").attr("disabled","disabled");
        console.log($(".table0002").find("input"));
      }else{

        $(".table0002").find("input").removeAttr("disabled");
      }
    })
    $(".table0002").find("input").blur(function () {
      if($(this).val()!=""){
        $(".frmid").attr("disabled","disabled");
      }else{
        $(".frmid").removeAttr("disabled");
      }
    })

var _data="";
$(".select01").click(function () {
  $.ajax({
    url:"/feign/drugStorageController/findFrmByfrmid",
    type:"get",
    data:{"frmid": $(".frmid").val()},
    headers: {
      Accept: "application/json; charset=utf-8",
      Authorization: location.href.split("=")[1]
    },
    dataType:"json",
    success:function (data) {
      if(data==null){
        alert("查询失败，请重新输入");
      }
      for(var i=0; i < data.length;i++) {
        var _html = "  <tr> \n" +
                "    <td class=\"frmid\">" + data[i].frmid + "</td>\n" +
                "    <td class=\"td07\">" + data[i].staffinfo.staname + "</td>\n" +
                "    <td class=\"td07\">" + data[i].frmdate + "</td>\n" +
                "    <td class=\"td07\">" + data[i].frmcheckdate + "</td>\n" +
                "    <td class=\"td07\">\n" +
                "      <button type='button' name='addgoods' data-toggle='modal' aria-pressed='false' data-target='#exampleModalCenter3' class='select' ><span >查看</span></button>\n" +
                "    </td>\n" +
                "  </tr>";
      }
      $("._tr1").nextAll("tr").remove();
      $(".table01>").append(_html);
      $(".select").on("click",function () {

        _selectDrug();
        $.ajax({
          url: "/feign/drugStorageController/findDamageByFrmid",
          data: {"frmid": $('td.frmid').html()},
          type: "get",
          headers: {
            Accept: "application/json; charset=utf-8",
            Authorization: location.href.split("=")[1]
          },
          dataType: "json",
          success: function (data) {
            if(data==null){
              alert("查询失败，请重新输入");
            }
            for(var i = 0; i<data.length;i++){

              $("#tbody").append("<tr>\n" +
                      "        <td class=\"td\">"+data[i].damid+"</td>\n" +
                      "        <td class=\"td_\">"+data[i].druginformation.drugname+"</td>\n" +
                      "        <td class=\"td_\">"+data[i].damnum+"</td>\n" +
                      "        <td class=\"td_\">"+data[i].druginformation.drugprice+"</td>\n" +
                      "        <td class=\"td_\">"+data[i].damdate+"</td>\n" +
                      "        <td class=\"td_\">"+data[i].damreason+"</td>\n" +
                      "        <td class=\"td_\">"+data[i].damnum*data[i].druginformation.drugprice+"</td>\n" +
                      "      </tr>\n");
            }
          }
        })
      })
    }
  })

})

$(".select02").click(function () {

    $.ajax({
      url:"/feign/drugStorageController/findFrmByfrmid",
      type:"get",
      data:{"staid":$(".staid").val(),"frmdate":$(".frmdate").val()},
      dataType:"json",
      headers: {
        Accept: "application/json; charset=utf-8",
        Authorization: location.href.split("=")[1]
      },
      success:function (data) {
        if(data==null){
          alert("查询失败，重新输入查询")
        }
        var _html="";
        // debugger;
        console.log(data.length)
        for(var i=0; i < data.length;i++){

          _html+="  <tr> \n" +
                  "    <td class=\"frmid\">"+data[i].frmid+"</td>\n" +
                  "    <td class=\"td07\">"+data[i].staffinfo.staname+"</td>\n" +
                  "    <td class=\"td07\">"+data[i].frmdate+"</td>\n" +
                  "    <td class=\"td07\">"+data[i].frmcheckdate+"</td>\n" +
                  "    <td class=\"td07\">\n" +
                  "      <button type='button' name='addgoods' data-toggle='modal' aria-pressed='false' data-target='#exampleModalCenter3' class='select' ><span >查看</span></button>\n" +
                  "    </td>\n" +

                  "  </tr>";
        }


        $("._tr1").nextAll("tr").remove();
        $(".table01>").append(_html);
        console.log(_html)
        // $("._tr1").after(_html);
        $(".select").on("click",function () {
          _selectDrug()
          $.ajax({
            url: "/feign/drugStorageController/findDamageByFrmid",
            data: {"frmid": $('td.frmid').html()},
            type: "get",
            headers: {
              Accept: "application/json; charset=utf-8",
              Authorization: location.href.split("=")[1]
            },
            dataType: "json",
            success: function (data) {
              if(data==null){
                alert("查询失败，请重新输入")
              }

              for(var i = 0; i<data.length;i++){

                $("#tbody").append("<tr>\n" +
                        "        <td class=\"td\">"+data[i].damid+"</td>\n" +
                        "        <td class=\"td_\">"+data[i].druginformation.drugname+"</td>\n" +
                        "        <td class=\"td_\">"+data[i].damnum+"</td>\n" +
                        "        <td class=\"td_\">"+data[i].druginformation.drugprice+"</td>\n" +
                        "        <td class=\"td_\">"+data[i].damdate+"</td>\n" +
                        "        <td class=\"td_\">"+data[i].damreason+"</td>\n" +
                        "        <td class=\"td_\">"+data[i].damnum*data[i].druginformation.drugprice+"</td>\n" +
                        "      </tr>\n");
              }
            }
          })
        })
      }
    })


})
<!--  弹窗-->
  function _selectDrug() {
    $("body").append(
            "<div class='modal fade' id='exampleModalCenter3' tabindex='-1' role='dialog' aria-hidden='true'>"+
            "<div class='modal-dialog modal-dialog-centered' role='document'>"+
            "<div class='modal-content'>"+
            "<div class='modal-header text-center'>"+
            "<label class='mb-2'>四川和平医院</label>"+
            "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>"+
            "<span aria-hidden='true'>&times;</span>"+
            "</button></div><div class='modal-body'><div class='login px-4 mx-auto mw-100'>"+
            "<form action='' method='post' enctype='multipart/form-data' id='goodsAdd'><div class='form-group'>"+
            // "<input class='browsers' list='browsers' placeholder='选择或输入添加商品类型'>"+
            "<label class='mb-2'>报损药品详情表格</label><br>"+
            "<div class=\"table-responsive\">\n" +
            "    <table class=\"table table-striped table-hover\" id='tbody'>\n" +
            "<tr>\n" +
            "\n" +
            "        <td class=\"td\">报损药品编号</td>\n" +
            "        <td class=\"td\">药品名称</td>\n" +
            "        <td class=\"td_\">药品报损数量</td>\n" +
            "        <td class=\"td_\">单价</td>\n" +
            "        <td class=\"td_\">报损日期</td>\n" +
            "        <td class=\"td_\">报损原因</td>\n" +
            "        <td class=\"td_\">总价</td>\n" +
            "      </tr>\n"+
            "    </table>\n" +
            "</div>"+
            "</form></div></div></div></div></div>")
  }

</script>